package max.ubitest.pipe.data
{
	import flash.events.EventDispatcher;
	import flash.utils.getDefinitionByName;
	import flash.utils.getQualifiedClassName;

	/**
	 * base class of all data type
	 * @author Max
	 * 
	 */	
	public class Data extends EventDispatcher
	{
		private var _source:Object;
		
		public function Data(value:Object = null)
		{
			_source = value;
			copyValue(value);
		}
		
		public function get source():Object{
			return _source;
		}
		
		public function copyValue(value:Object):void{
			if(value == null){
				return;
			}
			for(var i:Object in value){
				if(this.hasOwnProperty(i)){
					this[i] = value[i];
				}
			}
		}
		
		public function clone():Data{
			var className:String = getQualifiedClassName(this);
			var Refer:Class = getDefinitionByName(className) as Class;
			var self:Data = new Refer(this.source) as Data;
			return self;
		}
	}
}